import os 
import sys



class Plugin(object):
    pass


def load_plugins(plugins):
    plugins = plugins.split(',')
    for plugin in plugins:
        __import__(plugin, None, None, [''])


def init_plugin_system(cfg):
    if not cfg['plugin_path'] in sys.path:
        sys.path.insert(0, cfg['plugin_path'])
    load_plugins(cfg['plugins'])

def find_plugins():
    return Plugin.__subclasses__()

def get_plugin_by_capability(capability):
    for plugin in Plugin.__subclasses__():
        if capability == plugin.plugin_type:
            return plugin()
